#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
vector<int> div(vector<int> &A, int b, int &t)
{
    vector<int> c;
    for(int i = A.size() - 1; i >= 0; i--)
    {
        t = t * 10 + A[i];
        c.push_back(t / b);
        t %= b;
    }
    reverse(c.begin(), c.end());
    while(c.size() > 1 && c.back() == 0) c.pop_back();

    return c;
}
int main()
{
    string a;
    cin >> a;
    int b, i, t = 0;
    cin >>b;
    vector<int> A;
    for(i = a.size()- 1; i >= 0; i--) A.push_back(a[i] - '0');

    auto c = div(A, b, t);

    for(i = c.size() - 1; i >= 0; i--) printf("%d", c[i]);

    cout << endl << t << endl;

    return 0;
}
